package com.example.springbootlistener.config;

import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @program: springboot1
 * @description:
 * @author: zhanghz001
 * @create: 2020-12-09 14:15
 **/
public class MySpringApplicationRunnerListener implements SpringApplicationRunListener {

    public MySpringApplicationRunnerListener(SpringApplication application, String[] args) {
        System.out.println(application + "=============");
        System.out.println(args + "=======");
    }

    @Override
    public void starting(ConfigurableBootstrapContext bootstrapContext) {
        System.out.println("1-----SpringApplicationRunListener... starting...项目启动中");
    }

    @Override
    public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) {
        System.out.println("2-----SpringApplicationRunListener... environmentPrepared...项目环境准备完成");
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        System.out.println("3-----SpringApplicationRunListener... contextPrepared...上下文准备完成");
    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {
        System.out.println("4-----SpringApplicationRunListener... contextLoaded...上下文加载完成");
    }

    @Override
    public void started(ConfigurableApplicationContext context) {
        System.out.println("5-----SpringApplicationRunListener... started...启动完成");
    }

    @Override
    public void running(ConfigurableApplicationContext context) {
        System.out.println("6-----SpringApplicationRunListener... running...运行中");
    }

    @Override
    public void failed(ConfigurableApplicationContext context, Throwable exception) {
        System.out.println("7-----SpringApplicationRunListener... failed...失败执行完成");
    }
}
